<?php

include_once './db/AlarmDB.php';

// 累积达到3次就报警
class aaaRule
{
    public function check($one) {
        $count = 3; 
        $Alarm = new Alarm();
        $AlarmDB = new AlarmDB();
        $mark = $one['mark'];
        $maxId = $one['_id'];
        $db = $AlarmDB::connect();
        $res = $db->query("select * from t_alarm where 
            _id between 0 and {$maxId} and is_alarm = 'no' and mark = '{$mark}' order by touch_end_time desc");
        // throw new \Exception("缺少应用UID",1);
        // return $res;
        if(count($res)>=$count) {
            $arr = array_column($res,'_id');
            $updateRes = $Alarm->upDateIsAlarm($arr);  
            if($updateRes) return true;
            return false;
        }
        return false;
    }
}
